//https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded?tpId=37&tqId=21296&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
#include <iostream>
using namespace std;

int main() {
    int year = 0, month = 0, day = 0;
    cin >> year >> month >> day;
    int count[] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
    int sum = count[month] + day;
    if(month > 2 && year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
    sum++;

    cout << sum << endl;
    return 0;
}